<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>

</head>
<body>

<div id="app">

    <div class="demo-input-size">

        <el-input
                size="medium"
                placeholder="请输入姓名"
                suffix-icon="el-icon-date"
                style="display: inline-block;width: 200px;"
                v-model="searchInfo.name"
        >
        </el-input>

        <el-input
                size="medium"
                placeholder="请输入职位"
                suffix-icon="el-icon-date"
                style="display: inline-block;width: 200px;"
                v-model="searchInfo.rname"
        >
        </el-input>

        <el-button icon="el-icon-search" type="brand" circle @click="searchStu()" ></el-button>


        <el-table
                :data="staArr"
                border
                style="width: 100%">
            <el-table-column
                    prop="id"
                    label="编号"
                    width="150">
            </el-table-column>
            <el-table-column
                    prop="name"
                    label="姓名"
                    width="200">
            </el-table-column>

            <el-table-column
                    prop="role.rname"
                    label="职位"
                    width="200">
            </el-table-column>

            <el-table-column
                    prop="department.kname"
                    label="科室"
                    width="200">
            </el-table-column>

            <el-table-column
                    prop="adminState.state"
                    label="状态"
                    width="200">
            </el-table-column>

            <el-table-column
                    fixed="right"
                    label="操作"
                    >
                <template slot-scope="scope">
                    <el-button type="warning" size="small" @click="updatePeople(scope.row.id)">离职</el-button>
                    <el-button type="primary" size="small" @click="peopleUpdate(scope.row.id)">复职</el-button>
                </template>
            </el-table-column>
        </el-table>
        <el-pagination
                background
                @current-change="handleCurrentChange"
                layout="prev, pager, next"
                :total="totalCount">
        </el-pagination>

    </div>

</div>


<script>

    var haha=new Vue({
        el:"#app",
        data:{
            searchInfo:{
                name:"",
                rname:""
            },
            staArr:[],
            totalCount:0,
        },
        methods:{

            searchStu(){
                getData(1,10);
            },
            handleCurrentChange( val ){
                getData(val,10);
            },

            updatePeople(id){
                haha.$confirm('确认离职吗?', '温馨提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    $.get("/ssm/sta/updatePeo/"+id ,function (backData) {
                        haha.$message.success(backData.msg);
                        getData(1,10);
                    })
                });
            },

            peopleUpdate(id){
                haha.$confirm('确认复职吗?', '温馨提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    $.get("/ssm/sta/peoUpdate/"+id ,function (backData) {
                        haha.$message.success(backData.msg);
                        getData(1,10);
                    })
                });
            }

        }
    });

    function getData(a,b) {
        haha.searchInfo.pageNo=a;
        haha.searchInfo.pageCount=b;
        $.post("/ssm/sta/query",haha.searchInfo,function (backData) {
            haha.staArr=backData.data.currentData;
            haha.totalCount=backData.data.totalCount;
        });
    }

    getData(1,10);


</script>

</body>
</html>